<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<input name="he" type="button" value="请输入正确的邮箱地址" onclick=
			"ema(prompt('请输入正确的邮箱地址','susan@sohu.com'))" />
		<script type="text/javascript">
			function ema(per){
				var a=per.indexOf('@');
				var b=per.indexOf('.');
				if(per.length!=0){
					if(a!=-1&&b!=-1&&b>a){
						var c=per.substring(0,a);
						alert("邮箱地址正确，邮箱名称是："+c);
					}else{
						alert("邮箱地址必须包含@和.");
					}
				}else{
					alert("邮箱不能为空");
				}
			}
		</script>
	</body>
</html>
